import 'package:appflutterhomeschool/res/styles.dart';
import 'package:appflutterhomeschool/ui/widgets/general_page_jump_widget.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';

///回复信件状态管理
class ReplyLetterViewModel extends ChangeNotifier {
  BuildContext me;
  List<String> imageUrlList = [];
  List<String> imageUrlList2 = [
    "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2853553659,1775735885&fm=26&gp=0.jpg",
    "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2853553659,1775735885&fm=26&gp=0.jpg",
    "https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2853553659,1775735885&fm=26&gp=0.jpg",
  ];
  ReplyLetterViewModel(this.me);

  initView() {
  }

  Widget pictureItemWidget() {
    return Visibility(
      child: GeneralPageJumpWidget(
        image: "fujian",
        title: "添加附件：",
        textTitleStyle: TextStyles.textDark37,
        onTap: () {
          getImageUrl();
        },
      ),
    );
  }

  // ignore: missing_return
  Future getImageUrl() {
    ImagePicker().getImage(source: ImageSource.gallery).then((value) {
      imageUrlList.add(value.path);
      notifyListeners();
    });
  }
  //删除图片
  deleteIndex(index){
    imageUrlList.removeAt(index);
    notifyListeners();
  }
}
